<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
<script>
    var data1 =[{
        id:1,
        name:'aaa'
      },
      {
        id:2,
        name:'aaa'
      },
      {
        id:3,
        name:'aaa'
      },
      {
        id:31,
        name:'dd'
      }
    ];
    var data2 =[{
      id:1
    },
      {
        id:2
      },
      {
        id:3
      },
      {
        id:24
      },
      {
        id:5
      }]
    // data1.map((el,index)=>{
    //     data2.map((el2,index2)=>{
    //       if(el.id==el2.id){
    //         console.log(index)
    //         data1.splice(index,1);
    //         index--;
    //       }
    //     })
    // })
    for(var i =0;i<data1.length;i++){
        for(var j=0;j<data2.length;j++){
            console.log(data2[j])
            // if(data1[i].id==data2[j].id){
            //     data1.splice(i,1);
            //     i--;
            // }

        }
    }
    console.log(data1)
    console.log(data2)
</script>
</body>
</html>
